﻿using System.Configuration;

namespace kinokasse.belegungenrepo.tests
{
    class TestConfigurationHelper
    {
        public static void SetConnectionString(string connectionStringValue)
        {
            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            var connectionString = config.ConnectionStrings.ConnectionStrings[(string)DocumentStoreFactory.ConnectionStringName];

            if (connectionString == null)
                config.ConnectionStrings.ConnectionStrings.Add(
                    new ConnectionStringSettings(belegungenrepo.DocumentStoreFactory.ConnectionStringName, connectionStringValue));
            else
                connectionString.ConnectionString = connectionStringValue;
            config.Save();

            ConfigurationManager.RefreshSection("connectionStrings");

        }
    }
}
